<script language="javascript" type="text/javascript" src="__PUBLIC__/js/My97DatePicker/WdatePicker.js"></script>
<div class="search">
<form method="get">
<input type="text" name="keyword" title="关键字" class="input-m" value="{$keyword}" id="keywords" placeholder="请输入产品ID或者名称">
<input type="submit" class="button-green" value="查  询" id="keywords">
</form>
</div>
<table class="list">
		<thead>
		<tr>
      <th>产品ID</th>
      <th>图片</th> 
      <th>标题</th>
      <th>分类</th>
      <th>供应商</th>
      <th>发布时间</th>
      <th>操作</th>
  	</tr>
		</thead>
    <tbody>
		<foreach name='list' item='v'>
        <tr>
           <td>{$v.id}</td>
            <td>
              <img src="<if condition='$v.litpic eq null'>__PUBLIC__/image/product.jpg<else/>__URL__{$v.litpic}</if>" width="220" />
           </td> 
           <td class="title" width="23%">{$v.title}</td>
           <td>
           		<foreach name="v.category" item="cate" >
                {$cate}||
              	</foreach>
           </td>
           <td>{$v.supplier}</td>
           <td>{$v.dateline}</td>
           <td width="18%">
               <a href="__URL__/Product/details/id/{$v['id']}" target="_blank">查看</a>&nbsp;&nbsp;
               <a href="{:U(MODULE_NAME.'/Product/edit',array('id' => $v['id']), '')}">编辑</a>&nbsp;&nbsp;
               <a href="javascript:" onclick="Up('{$v['id']}','{$v['title']}')">上架</a>&nbsp;&nbsp;
               <a href="javascript:;" onclick="toConfirm('{:U(MODULE_NAME.'/Product/del',array('id' => $v['id']), '')}', '确实要删除吗？')">删除</a>
           </td>
       </tr>
      </foreach>
 </tbody>
</table>
<div class="page" style="clear: both;">{$page}</div>
<script type="text/javascript">
function Up(id,title)
{
	//<p><a href="javascript:" onclick="$(\'#form_do\').submit();"class="button-blue">确定</a> <a href="javascript:" class="button-red layer-close">取消</a></p>
	var Div = layer.open({
	    type: 1,
	    title: '产品上架',
	    area: ['450px', '200px'],
	    shift: 0, //从左动画弹出
	    content: '<div class="layer-content"><form method="post" id="layerDiv" name="form_do" action="/Home/Product/marketIn.html"><p>你现在上架的是：'+title+'</p><p>下架时间：<input class="Wdate" type="text" style="width:120px;padding:2px 5px;" onclick="WdatePicker()" name="enddate" value=""><input type="hidden" name="id" value="'+id+'"></p></form></div>',
	    btn:['确定','取消'],
	    yes: function(index){
	    	$('#layerDiv').submit();
	    }, 
	    cancel: function(){
	    	layer.close(Div);
	    }
	});
}

//取得所有CSS样式为 ".title" 的对象，并对默认自定义的方法进行遍历操作

$(".title").each(function(){

    //取得标签的文本

    var t = $(this).text();



    //获取关键字

    var keywords =$('#keywords').val();



    //取得需要查出的关键字，我们这里假定是多关键字以","间隔

    var array = (keywords).split(",");



    //开始用关键字遍历标签文本

    for(var i=0;i<array.length;i++){



        //判断标签是否包含关键字

        if(t.indexOf(array[i])>-1){



         //定义正则表达式对象  array[i]是关键字   "g"是指全局范围

         var a = new RegExp(array[i],"g")



         //对标签文本进行全局替换，包含关键字的位置替换为加红字span对象

         t = t.replace(a,("<span style='color:red; font-weight: bold; '>" + array[i] + "</span>"));



         //将替换完的文本对象赋给此对象中A标签对象的html值中

         $(this).html(t);

        }

    }

});
</script>